<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象继承</title>
</head>
<body>
    <script>
        //手机类
        function Phone(brand, price){
            this.brand = brand;
            this.price = price;
        }
        //父类的方法
        Phone.prototype.call = function(){
            console.log('我可以打电话...');
        }

        //智能手机
        function SmartPhone(brand, price, storage, pixel){
            //属性的初始化
            Phone.call(this, brand, price);
            //
            this.storage = storage;//内存
            this.pixel = pixel;//像素
        }

        //子类添加方法  子类的原型为父类的实例
        SmartPhone.prototype = new Phone();
        //修正
        SmartPhone.prototype.constructor = SmartPhone;
        //添加子类方法
        SmartPhone.prototype.videoChat = function(){
            console.log('视频聊天');
        }
        SmartPhone.prototype.playGame = function(){
            console.log('玩游戏');
        }

        let chuizi = new SmartPhone('锤子', 2500, '64G', '800w');

        // console.log(chuizi);
        chuizi.call();
        chuizi.playGame();

    </script>
</body>
</html>